<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维保费金额明细列表')" />
</head>
<body class="gray-bg">
    <div style="background-color: white">
        <a class="btn btn-info btn-outline visible-xs-block" href="#" onclick="$.modal.closeTab()">返&nbsp回</a>
    </div>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse" hidden>
                <form id="formId" th:object="${mtContractId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px">维保费总金额：</label>
                                <input type="text" name="mtCostPrice"/>
                            </li>
                            <li>
                                <label style="width: 120px;">维保费已支付金额：</label>
                                <input type="text" name="mtCostPaid"/>
                            </li>
                            <li>
                                <label style="width: 120px;">维保费未支付金额：</label>
                                <input type="text" name="mtCostUnpaid"/>
                            </li>
                            <li>
                                <label style="width: 120px">维保费支付状态：</label>
                                <input type="text" name="mtCostIspaid"/>
<!--                                <select name="mCoststatus" th:with="type=${@dict.getType('maintenance_coststatus')}">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
                            </li>
<!--                            <li>-->
<!--                                <label>伪外键：</label>-->
<!--                                <input type="text" name="mtContractId"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel(mtContractId)" shiro:hasPermission="ruoyi:priceing:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:price:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:price:remove')}]];
        var prefix = ctx + "ruoyi/priceing";
        var mtContractId=[[*{mtContractId}]];
        var mtCostIspaid = [[${@dict.getType('mtprice_status')}]];
        $(function() {
            var options = {
                url: prefix + "/lists/"+mtContractId,
                showFooter:true,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export/"+mtContractId,
                striped: true,
                showColumns: false,
                onLoadSuccess: onLoadSuccess,
                modalName: "维保费金额明细",
                columns: [
                {
                    field: 'mtCostId', 
                    title: '维保费用id',
                    visible: false
                },
                {
                    //field: 'mtCostPrice',
                    title: '维保费总金额',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('￥'+row.mtCostPrice);
                        return actions.join('');
                    },
                    footerFormatter: function(value){
                        var sum = 0;
                        for (var i in value) {
                            sum += parseFloat(value[i].mtCostPrice)
                        }
                        return "维保费用总金额: ￥"+sum;
                    },
                },
                {
                   field: 'mtCostPaid',
                    title: '维保费已支付金额',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.mtCostPaid==null){
                            actions.push('￥'+0.00);
                            return actions.join('');
                        }else{
                            actions.push('￥'+row.mtCostPaid);
                            return actions.join('');
                        }
                    },
                    footerFormatter: function(value){
                        var sum = 0;
                        for (var i in value) {
                            sum += parseFloat(value[i].mtCostPaid)
                        }
                        if(sum==null){
                            return "已支付总金额: ￥"+0;
                        }else{
                            return "已支付总金额: ￥"+sum;
                        }

                    },
                    cellStyle:{
                        css:{"color":"#0000EE"}
                    }
                },
                    {
                        field: 'mtCostUnpaid',
                        title: '维保费未支付金额',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if(row.mtCostUnpaid==null){
                                actions.push('￥'+row.mtCostPrice)
                                return actions.join('');
                            }
                            actions.push('￥'+row.mtCostUnpaid);
                            return actions.join('');
                        },
                        footerFormatter: function(value){
                            var sum = 0;
                            for (var i in value) {
                                sum += parseFloat(value[i].mtCostUnpaid)
                            }
                            if(sum==null){
                                return "未支付总金额: ￥"+0;
                            }else{
                                return "未支付总金额: ￥"+sum;
                            }
                        },
                        cellStyle:{
                            css:{"color":"#0000EE"}
                        }
                    },
                    {
                        field: 'mtCostDate',
                        title: '维保费支付日期',
                    },
                {
                    field: 'mtCostIspaid', 
                    title: '维保费是/否全部支付',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mtCostIspaid, value);
                    }
                },
                {
                    field: 'mtContractId', 
                    title: '伪外键',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mtCostId + '\')"><i class="fa fa-edit"></i>添加付款金额</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mtCostId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function onLoadSuccess() {
            $(".fixed-table-body").on("scroll",function(){
                var sl=this.scrollLeft;
                $(this).next()[0].scrollLeft = sl;
            })
        }
    </script>
</body>
</html>